import cn from "classnames";
import { useState } from "react";

type Props = {
  className?: string;
  onSend?: (message: string) => void;
};

export default function InputArea({ className, onSend }: Props) {
  const [message, setMessage] = useState<string>("");
  return (
    <textarea
      value={message}
      onChange={(e) => setMessage(e.target.value)}
      onKeyUp={(e) => {
        if (e.key === "Enter" && message) {
          onSend?.(message);
          setMessage("");
        }
      }}
      className={cn(
        "border border-indigo-100 rounded-md p-2 resize-none w-full bg-white",
        className,
      )}
    />
  );
}
